Add Warning for Long-Running Message Handlers in Debug Mode #1
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
This PR addresses issue Textualize#4895
Implemented Features:
-Configurable Threshold: The time threshold before a warning is issued can be set via the TEXTUAL_SLOW_THRESHOLD_MS environment variable.
Known Limitations:
Currently, the warning is logged only after the message handler completes. This means that if a handler takes an extended time (e.g., 30 seconds), the warning won’t appear until it finishes.
I have attempted to implement a solution that handles this case in real-time but haven't been able to get it working as intended yet.
Request for Feedback:
If the current implementation is satisfactory, I would appreciate feedback on how to improve the async version for real-time warnings.
Additional Notes:
I am open to any feedback since this is my first code-related PR, and I’m eager to learn and improve.